package org.genew.squadra.xml.presentation;

import java.util.ArrayList;
import java.util.List;

import org.genew.squadra.xml.model.MyFileForm;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
 
@Controller
public class FileUploadController {
     
    @RequestMapping(value = "/show", method = RequestMethod.GET)
    public String displayForm(Model mod) {
    	mod.addAttribute("myfileform",new MyFileForm());
        return "epub.file_upload_form";
    }
     
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public String save(
            @ModelAttribute("myfileform") MyFileForm uploadForm,
                    Model map) {
//         
//        List<MultipartFile> files = uploadForm.getFiles();
//        
//        List<String> fileNames = new ArrayList<String>();
//         
//        if(null != files && files.size() > 0) {
//            for (MultipartFile multipartFile : files) {
// 
//                String fileName = multipartFile.getOriginalFilename();
//                fileNames.add(fileName);
//                //Handle file content - multipartFile.getInputStream()
// 
//            }
//        }
//         
//        map.addAttribute("files", fileNames);
        return "common.file_upload_success";
    }
}